#!/usr/bin/python3
# -*- coding:utf-8 -*-
# @Time : 2018/9/18 下午3:56
# @Author : Desunire
# @projectname : bzShop
# @name: serializers

from rest_framework import serializers
from .models import Goods,GoodsCategory,GoodsImage

from rest_framework import status

class CategorySerializer3(serializers.ModelSerializer):
    class Meta:
        model = GoodsCategory
        fields = "__all__"


class CategorySerializer2(serializers.ModelSerializer):
    sub_cat = CategorySerializer3(many=True)
    class Meta:
        model = GoodsCategory
        fields = "__all__"

class CategorySerialzers(serializers.ModelSerializer):
    sub_cat = CategorySerializer2(many=True)
    class Meta:
        model = GoodsCategory
        fields = "__all__"


class GoodsImageSerializer(serializers.ModelSerializer):
    class Meta:
        model = GoodsImage
        fields =("image", "add_time")


class GoodsSerializers(serializers.ModelSerializer):
    category = CategorySerialzers()
    images = GoodsImageSerializer(many=True)
    class Meta:
        model = Goods
        fields = "__all__"



